package com.kinghunt.misp.common.enums.devicex;

import lombok.Getter;
import org.apache.commons.collections.map.HashedMap;

import java.util.*;

/**
 * 设备状态类型枚举
 */
public enum DeviceTypeEnum {

    /**
     * 设备状态（1:启用、2:停用、3:流转、4:报废、5:维修）
     */
    DEVICE_TYPE_1(1, "启用"),
    DEVICE_TYPE_2(2, "停用"),
    DEVICE_TYPE_3(3, "流转"),
    DEVICE_TYPE_4(4, "报废"),
    DEVICE_TYPE_5(5, "维修");

    @Getter
    private Integer value;
    @Getter
    private String desc;

    DeviceTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    private final static Map<Integer, DeviceTypeEnum> map = new HashMap<>(8);
    static {
        for (DeviceTypeEnum e : DeviceTypeEnum.values()) {
            map.put(e.getValue(), e);
        }
    }

    public static DeviceTypeEnum getByType(Integer value) {
        if (Objects.isNull(value)) {
            return null;
        }
        return map.get(value);
    }
}
